package com.itcast.admin.controller;


import com.itcast.admin.domain.CheckupGroup;
import com.itcast.admin.domain.request.CreateGroupReqDTO;
import com.itcast.admin.domain.request.GroupPageReqDTO;
import com.itcast.admin.domain.response.CheckDisableResDTO;
import com.itcast.admin.domain.response.GroupListResDTO;
import com.itcast.admin.domain.response.GroupPageResDTO;
import com.itcast.admin.service.ICheckupGroupService;
import com.jzo2o.common.model.PageResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 体检组 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-11-04
 */
@RestController
@RequestMapping("/admin/check-group")
@Api(tags = "体检组相关接口")
public class CheckupGroupController {

    @Autowired
    private ICheckupGroupService checkupGroupService;
    @GetMapping("/pageQuery")
    @ApiOperation("获取体检组列表")
    public PageResult<GroupPageResDTO> pageQuery(GroupPageReqDTO groupPageReqDTO) {
        return checkupGroupService.pageQuery(groupPageReqDTO);
    }
    @PostMapping()
    @ApiOperation("新增体检组列表")
    public void insert(@RequestBody CreateGroupReqDTO createGroupReqDTO) {
        checkupGroupService.insert(createGroupReqDTO);
    }

    @GetMapping("/{id}")
    @ApiOperation("根据id查询体检组")
    public CheckupGroup getCheckGroupById(@PathVariable Integer id) {
        return checkupGroupService.getCheckGroupById(id);
    }

    @PutMapping("/{id}")
    @ApiOperation("根据id修改体检组")
    public void updateCheckGroupById(@PathVariable Integer id,@RequestBody CreateGroupReqDTO createGroupReqDTO) {
        checkupGroupService.updateCheckGroupById(id,createGroupReqDTO);
    }
    @PutMapping("/enable/{id}")
    @ApiOperation("根据id启用体检组")
    public void enableCheckGroupById(@PathVariable Integer id) {
        checkupGroupService.enableCheckGroupById(id);
    }

    @PutMapping("/disable/{id}")
    @ApiOperation("根据id禁用体检组")
    public void disableCheckGroupById(@PathVariable Integer id) {
        checkupGroupService.disableCheckGroupById(id);
    }

    @GetMapping("/checkDisable/{id}")
    @ApiOperation("校验体检组是否可以禁用")
    public CheckDisableResDTO checkDisableById(@PathVariable Integer id) {
        return checkupGroupService.checkDisableById(id);
    }

    @DeleteMapping("/{id}")
    @ApiOperation("根据id删除体检组")
    public void deleteCheckGroupById(@PathVariable Integer id) {
        checkupGroupService.deleteCheckGroupById(id);
    }
    @GetMapping("/listForFilter")
    @ApiOperation("体检组下拉列表")
    public List<GroupListResDTO> listForFilter(Integer groupStatus) {
        return checkupGroupService.listForFilter(groupStatus);
    }


}
